package cc.wsyw126.java.nowcoder.offerdidi;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * Created by dp on 17/3/30.
 */
public class Main {
    public static void main(String[] args) {
        class Node {
            int x;
            int y;

            public Node(int x, int y) {
                this.x = x;
                this.y = y;
            }
        }
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            String[] split = s.split(" ");
            int n = Integer.valueOf(split[0]), m = Integer.valueOf(split[1]);

            String s1 = sc.nextLine();
            String[] split1 = s1.split(" ");
            s1 = null;
            String s2 = sc.nextLine();
            String[] split2 = s2.split(" ");
            s2 = null;

            ArrayList<Node> nodes = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                Node node = new Node(Integer.valueOf(split1[i]), Integer.valueOf(split2[i]));
                nodes.add(node);
            }


            int mark = Integer.MAX_VALUE;
            List<Node> collect = null;
            for (int i = 0; i < m; i++) {
                String s3 = sc.nextLine();
                String[] split3 = s3.split(" ");
                s3=null;
                int A = Integer.valueOf(split3[0]), B = Integer.valueOf(split3[1]);
                if (A>mark) {
                    collect = collect.stream().filter(node -> node.x >= A).collect(Collectors.toList());
                } else {
                    collect = nodes.stream().filter(node -> node.x >= A).collect(Collectors.toList());
                }
                mark = A;
                long count = collect.stream().filter(node -> node.y >= B).count();
                System.out.println(count);
            }

        }
    }

}
